package org.wanda.pv.service.view.impl;

import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.lang.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import org.wanda.pv.framework.page.Pagination;
import org.wanda.pv.model.view.PointInfoView;
import org.wanda.pv.model.view.PointSearchView;
import org.wanda.pv.service.BaseServiceImpl;
import org.wanda.pv.service.view.PointViewService;

@Service
public class PointViewServiceImpl extends BaseServiceImpl<PointInfoView> implements PointViewService{

    @Autowired
    public PointViewServiceImpl(Dao dao) {
        super(dao);
    }

    @Override
    public Pagination listByView(int pageNo,
                                int pageSize,
                                 PointSearchView pointSearchView) {

        Cnd cnd = Cnd.where("delFlag","=",false);

        // 题目名称
        if (Strings.isNotBlank(pointSearchView.getName())){
            cnd.and("name","like","%"+pointSearchView.getName()+"%");
        }


        // 专业分类
        if (Strings.isNotBlank(pointSearchView.getSpecialtyName())){
            cnd.and("specialtyNames","like","%"+pointSearchView.getSpecialtyName()+"%");
        }

        // 系统
        if (Strings.isNotBlank(pointSearchView.getSystemName())){
            cnd.and("systemName","like","%"+pointSearchView.getSystemName()+"%");
        }


        if (Strings.isNotBlank(pointSearchView.getPointRoomName())){
            cnd.and("pointRoomName","like","%"+pointSearchView.getPointRoomName()+"%");
        }


        return this.listPage(pageNo,pageSize,cnd);
    }
}
